<template>
  <div class="app-container">
    <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane label="箱内饰品配置" name="fontconfig" />
      <el-tab-pane label="用户通道配置" name="openboxconfig" />
      <div class="tab-content">
        <!-- <keep-alive> 组件name或者路由 -->
        <component :is="curTabcompnents[activeName]" />
        <!-- </keep-alive> -->
      </div>

    </el-tabs>
  </div>
</template>

<script>

import FontProbilityConfig from './components/FontProbilityConfig'
import OpenBoxProbilityConfig from './components/OpenBoxProbilityConfig'

export default {
  name: 'Tab',
  components: { FontProbilityConfig, OpenBoxProbilityConfig },
  data() {
    return {
      activeName: 'fontconfig',
      curTabcompnents: {
        'fontconfig': 'FontProbilityConfig',
        'openboxconfig': 'OpenBoxProbilityConfig'
      }
    }
  },
  watch: {
    activeName(val) {
      if(this.$route.query.permissionid){
        this.$router.push(`${this.$route.path}?tab=${val}&id=${this.$route.query.id}&permissionid=${this.$route.query.permissionid}`)
      }else{
        this.$router.push(`${this.$route.path}?tab=${val}&id=${this.$route.query.id}&permissionid=${this.$route.query.permissionid}`)
      }
    }
  },
  created() {
    // init the default selected tab
    const tab = this.$route.query.tab
    if (tab) {
      this.activeName = tab
    }
  },
  methods: {
    handleClick(tab) {
      this.activeName = tab.name
    }
  }
}
</script>

<style lang="scss" scoped>
.app-container{
  padding:0px;
}

</style>
